< previous page page_964 next page >

Page 964
5. A WHERE clause can be used to limit the records that are selected by the SQL statement, as well as to link two or more tables in a result set.
6. Use the AS clause to rename a field heading. For example, issue the following SQL statement to rename the field CustomerID in the Customers table to Customer.
SELECT CustomerID AS Customer FROM Customers
7. SQL aggregate functions are a core set of functions available in all SQL-compliant systems used to return computed results on numeric data fields. The functions available through Jet include AVG, COUNT, SUM, MAX, and MIN.
8. Chief among the drawbacks of using Visual Basic functions in your SQL statement is the loss of portability to other database engines. There is also a slight performance reduction when Visual Basic functions are used in your SQL statement.
9. Both the DISTINCT and DISTINCTROW clauses extract unique records. The DISTINCTROW command looks at the entire record, whereas DISTINCT looks at the fields you associate with it.
10. You should always use the ORDER BY clause when you use the TOP n or TOP n PERCENT clauses. The ORDER BY clause ensures that your data is sorted appropriately to allow the TOP n clauses to select the appropriate data.
11. The three types of joins found in Microsoft Access Jet SQL are INNER, LEFT, and RIGHT. An INNER JOIN is used to create updatable result sets whose records have an exact match in both tables. The LEFT JOIN is used to return an updatable result set that returns all records in the first table in your SQL statement, and any records in the second table that have matching column values. The RIGHT JOIN is just the opposite of the LEFT JOIN; it returns all records in the second table of your SQL statement and any records in the first table that have matching column values.
12. UNION queries are used to join tables that contain similar information but are not linked through a foreign key. An example of a UNION query would be listing all of your company's customers and suppliers located in the state of Iowa. There won't be any foreign key relationships between a data table of supplier's information and a table of customer's information. Both tables will, however, contain fields for names, addresses, and phone numbers. This information can be joined through a UNION query and displayed as one result.
Answers to Day 8 Exercises
1. SELECT * FROM CustomerMaster
2. SELECT InvoiceNo, CustomerID AS Account, Description, Amount FROM OpenInvoice
3. SELECT InvoiceNo, CustomerID AS Account, Description, Amount FROM OpenInvoice ORDER BY CustomerID, InvoiceNo

 
< previous page page_964 next page >

If you like this book, buy it!